<?php
//==============================================
// 代码所有       PHPText.Net
// 代码作者       黄创钦,tine2cx@163.com
// 联系方式       QQ 233944397
// 本代码开源使用，可以随意修改传播，但请保留本版权
// 声明,谢谢合作！
//==============================================


	define("_NavLV_","Index");  //定义当前页面下拉菜单等级
	include "_Global.php";

	$BoardInfo = TextDB_SearchData("Board");  //获取板块信息
	if($BoardInfo)
	{
		foreach($BoardInfo as $K=>$Board)
		{
			unset($Forum);
			$BoardID             = $Board['TEXTDB_HID'];  //获取板块ID
			$Boards[$K]['ID']    = $Board['TEXTDB_HID'];
			$Boards[$K]['Title'] = $Board["分类名称"];
			$Boards[$K]['Alt']   = $Board["分类描述"];
			$root = explode("",$Board["SID管理员"]);

			if($root[1]=="暂无") $root[1] = "";
			$Boards[$K]['Root']     = $root[1]; //获取板块版主
			$Boards[$K]['AdminUrl'] = "profile.php?action=view&uid=".$root[0];

			//检测是否为分类管理人员
			if(CheckBoardRoot($BoardID) || CheckForumAdmin() || CheckForumRoot())
			{
				$Boards[$K]['RootModeDisplay'] = 1;
			}
			else
			{
				$Boards[$K]['RootModeDisplay'] = 0;
			}

			$ForumInfo = TextDB_SearchData("Forum_B".$BoardID);  //获取子板块信息
			if($ForumInfo)
			{
				foreach($ForumInfo as $FK=>$Forums)
				{
					$ForumID                          = $Forums[0];
					$Forum[$FK]["BoardID"]            = $BoardID;  //获取子板块ID

					//获取子板块模式
					if($Forums["论坛模式"])
					{
						$Forum[$FK]["Sta"]            = "锁";
					}
					else
					{
						$Forum[$FK]["Sta"]            = "无";
					}

					$Forum[$FK]["ID"]                 = $Forums['TEXTDB_HID'];  //获取子板块ID
					$Forum[$FK]["Title"]              = $Forums["论坛名称"];    //获取子板块ID
					$Forum[$FK]["Description"]        = $Forums["论坛描述"];    //获取子板块描述
					$Forum[$FK]["Topic"]              = $Forums["主题数"];      //获取主题数
					$Forum[$FK]["reTopic"]            = $Forums["帖子数"];      //获取帖子数
					$Forum[$FK]["TopicToday"]         = $Forums["今日帖子"];    //获取今日帖子数

					//获取最后发帖信息
					$TopicInfo = TextDB_SearchData("Topic_B".$BoardID."_F".$ForumID,null,null,'desc',null,0,1);
					if($TopicInfo)
					{
						$Forum[$FK]["IssuedTopicID"]      = $TopicInfo[0]['TEXTDB_HID'];  //获取最后帖ID
						$Forum[$FK]["IssuedTopicDate"]    = date('Y-m-d H:i:s',$TopicInfo[0]["创建时间"]);     //获取最后帖发布时间
						$Forum[$FK]["IssuedTopicTitle"]   = $TopicInfo[0]["主题"];         //获取最后帖主题
					}

					//获取发帖人信息
					$user=explode("",$TopicInfo[0]["SID发表人"]);
					$Forum[$FK]["IssuedTopicMemberID"]   = $user[0];   //获取发帖人ID
					$Forum[$FK]["IssuedTopicMemberName"] = $user[1];   //获取发帖人名称

					//获取版主信息
					if(isset($Forums["SID版主"]))
					{
						$admin=explode("",$Forums["SID版主"]);
					}

					if(isset($admin[0]))
					{
						$Forum[$FK]["AdminUrl"] = "profile.php?action=view&uid=".$admin[0];  //获取Url地址
					}
					else
					{
						$Forum[$FK]["AdminUrl"] = "javascript:;";  //获取无效Url地址
					}
					$Forum[$FK]["AdminName"]    = isset($admin[1]) ? $admin[1] : '暂无'; //获取版主名称
				}
				$Boards[$K]['Forum'] = $Forum;
			}
		}
	}

	if(CheckForumAdmin() || CheckForumRoot())
	{
		$ForumAdminModeDisplay = 1;
	}
	else
	{
		$ForumAdminModeDisplay = 0;
	}

	_Header(_ForumTitle_);
	require GetMod('Index');
	_Footer();

?>